package com.stationpc.androidtvrecents

import android.app.Application

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        if (!isValidDevice()) {
            android.os.Process.killProcess(android.os.Process.myPid())
        }
    }

    private fun isValidDevice(): Boolean {
        return try {
            val systemPropertiesClass = Class.forName("android.os.SystemProperties")
            val getMethod = systemPropertiesClass.getMethod("get", String::class.java, String::class.java)
            val buildUser = getMethod.invoke(null, "ro.build.user", "") as String
            val productModel = getMethod.invoke(null, "ro.product.system.model", "") as String
            buildUser == "mo123" && productModel == "Station_M3"
        } catch (e: Exception) {
            false
        }
    }
}
